
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mybox}[2023-05-02 v1.0 for test]

\RequirePackage{tcolorbox}
\RequirePackage{varwidth}
\tcbuselibrary{listings,skins,breakable,fitting}

\RequirePackage{accsupp}
\newcommand{\emptyaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}

%通用设定
\tcbset{breakable,fonttitle=\bfseries}
%定义tcblisting样式
\tcbset{
    codestyle/.style={breakable,skin=bicolor,colback=lightgray!20!white,
        colframe=red!75!black,listing only, 
        left=6mm,top=0pt,bottom=0pt,boxsep=0pt,fontupper=\ttfamily\small,beforeafter skip={1ex},
        % listing style
        listing options={numbers=left,numberstyle=\tiny\color{red!75!black}\emptyaccsupp ,
            breaklines=true,escapeinside=``}},
    codeupstyle/.style={breakable,skin=bicolor,colback=lightgray!20!white,
        colbacklower=orange!30!white,colframe=red!70!black, beforeafter skip={1ex},
        fontupper=\ttfamily\small,left=6mm,boxsep=0pt,top=-2pt,after upper={\vspace{-2ex}},
        % listing style
        listing and text,
        listing options={numbers=left,numberstyle=\tiny\color{red!75!black}\emptyaccsupp,
            breaklines=true,escapeinside=``}},
    codeleftstyle/.style={breakable,skin=bicolor,colback=lightgray!20!white,
        colbacklower=orange!30!white,colframe=red!75!black, 
        left=6mm,top=0pt,bottom=0pt,boxsep=0pt,beforeafter skip={1ex},
        fontupper=\ttfamily\small,
        % listing style
        listing side text,
        listing options={numbers=left,numberstyle=\tiny\color{red!75!black}\emptyaccsupp,
            breaklines=true,escapeinside=``}},}
%定义tcolorbox颜色样式
\tcbset{
    costg/.style={colframe=cogteal,colback=cobgray},
    cosgo/.style={colframe=cogreen,colback=coborange},
    cosrr/.style={colframe=cored,colback=cobred},
    cosry/.style={colframe=cored,colback=coyellow},
    cosryb/.style={colframe=cored,colback=cobyellow},
    cosrg/.style={colframe=cored,colback=cobgray},
}

\newtcolorbox{wisdom}[1][]{%
    coltitle=black,detach title,before upper{\par},after upper={\par\hfill\tcbtitle},parbox=false,title=#1,
}

%%定义tcblisting
\newtcblisting{code}{codestyle}
\newtcblisting{codeleft}{codeleftstyle}
\newtcblisting{codeup}{codeupstyle}

%%================命令、环境、宏包box================%%
\DeclareTotalTCBox{\opt}{ v }{
    verbatim,enhanced,skin=enhancedmiddle jigsaw,colframe=red,top=1pt,bottom=1pt,left=1pt,right=1pt,toprule=1pt,bottomrule=1pt,boxsep=1pt}{#1}
\newtcbox{\cmd}{on line,before upper=\ttfamily\char`\\,
    arc=0pt,outer arc=0pt,colback=green!10!white,colframe=green!50!black,
    boxsep=0pt,left=1pt,right=1pt,top=1pt,bottom=1pt,
    boxrule=0pt,bottomrule=1pt,toprule=1pt}
\newtcbox{\env}{on line,before upper=\ttfamily,
    arc=0pt,outer arc=0pt,colback=violet!70!cyan!10!white,colframe=violet!70!cyan!50!black,
    boxsep=0pt,left=1pt,right=1pt,top=1pt,bottom=1pt,
    boxrule=0pt,bottomrule=1pt,toprule=1pt}
\newtcbox{\pkg}{on line,before upper={\rule[-0.2ex]{0pt}{1ex}\ttfamily},
    arc=0.8ex,colback=orange!70!red!30!white,colframe=orange!70!red!50!black,
    boxsep=0pt,left=1.5pt,right=1.5pt,top=1pt,bottom=1pt,
    boxrule=1pt}
\newtcbox{\cls}{on line,before upper={\rule[-0.2ex]{0pt}{1ex}\ttfamily},
        arc=0.8ex,colback=olive!25!white,colframe=olive,
        boxsep=0pt,left=1.5pt,right=1.5pt,top=1pt,bottom=1pt,
        boxrule=1pt}


%%================列表风格和关键字================%%
\lstdefinestyle{mytexstyle}{language=[LaTeX]TeX,breaklines,
    basicstyle=\small\ttfamily,
    commentstyle=\color{cogreen},
    keywordstyle=\color{blue},
    stringstyle=\color{cogteal},
    showstringspaces=false,
    morekeywords={texdoc,latexdef,BeforeBeginEnvironment,AfterEndEnvironment,printindex,pdfbookmark,includepdf,includegraphics,setCJKfamilyfont,CJKfontspec,numexpr,lstset,listofchanges,added,deleted,replaced,highlight,comment,ctexset,raotatebox,resizebox,scalebox,colorbox,fcolorbox,color,setlength,subsection}
}    
\lstset{style=mytexstyle}